package com.api.shopapi.service.impl;

import com.api.shopapi.entity.DeviceXiaoLe;
import com.api.shopapi.entity.dto.DeviceXiaoLeDTO;
import com.api.shopapi.mapper.DeviceXiaoLeMapper;
import com.api.shopapi.service.DeviceXiaoLeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("DeviceXiaoLeServiceImplOne")
public class DeviceXiaoLeServiceImpl implements DeviceXiaoLeService {

    @Autowired
    private DeviceXiaoLeMapper deviceXiaoLeMapper;


    @Override
    public int insert(DeviceXiaoLe deviceXiaoLe) {
        return deviceXiaoLeMapper.insert(deviceXiaoLe);
    }

    @Override
    public int update(DeviceXiaoLe deviceXiaoLe) {
        return deviceXiaoLeMapper.update(deviceXiaoLe);
    }

    @Override
    public DeviceXiaoLe getByDeviceXiaoLeCode(String deviceXiaoLeCode) {
        return deviceXiaoLeMapper.getByDeviceXiaoLeCode(deviceXiaoLeCode);
    }

    @Override
    public DeviceXiaoLe getByUserCode(String userCode) {
        return deviceXiaoLeMapper.getByUserCode(userCode);
    }

    @Override
    public DeviceXiaoLe getBySn(String sn) {
        return deviceXiaoLeMapper.getBySn(sn);
    }

    @Override
    public int deleteByUserCode(String userCode) {
        return deviceXiaoLeMapper.deleteByUserCode(userCode);
    }

    @Override
    public DeviceXiaoLe getByClientId(String cid) {
        return deviceXiaoLeMapper.getByClientId(cid);
    }


    @Override
    public List<DeviceXiaoLeDTO> getListByGovernmentCode(String governmentCode) {
        return deviceXiaoLeMapper.getListByGovernmentCode(governmentCode);
    }

    @Override
    public PageInfo<DeviceXiaoLeDTO> getPage(int pageIndex, int pageSize, String phone, String sn) {
        PageHelper.startPage(pageIndex,pageSize);
        List<DeviceXiaoLeDTO> deviceXiaoLeDTOList = deviceXiaoLeMapper.getPage(phone, sn);
        return new PageInfo<>(deviceXiaoLeDTOList);
    }
}
